When an object is created with a setter for a property but without a getter for that property, the property is inaccessible and is thus
useless.
This rule also enforces the reverse situation (getter but no setter).
Noncompliant code example
var obj = {
set foo(value) {
this.fooval = value;
}
};
Compliant solution
var obj = {
set foo(value) {
this.fooval = value;
},
get foo() {
return this.fooval;
}
};
or
var obj = {
setFoo(value) { // a standard method, not a setter
this.fooval = value;
}
};